/**
 * 
 */
package org.dragonfire.dasm.directives;

import java.util.ArrayList;

import org.dragonfire.dasm.Command;
import org.dragonfire.dasm.Listing;
import org.dragonfire.dasm.DirectiveManager.Directive;
import org.dragonfire.parser.Equation;
import org.dragonfire.util.DString;

/**
 * Generates a warning that is printed in the log file.<br />
 * <br />
 * Format:<br />
 * <code>#WARN <i>&lt;arg1&gt;</i>[,<i>&lt;arg2&gt;</i>[,<i>...</i>]]</code><br />
 * <br />
 * Parameters:<br />
 * <table>
 * <tr>
 * <td><code>arg1</code></td>
 * <td> (Double/String) The string or number to print out as a warning message</td>
 * </tr>
 * </table><br />
 * Errors:<br />
 * <i>None</i>
 * 
 * @see org.dragonfire.dasm.DASM#warn(String, Object...)
 * @author Darth Android
 * @version 2.0
 */
public class Warn extends Directive {

	/**
	 * {@inheritDoc}
	 */
	@Override
	public ArrayList<Listing> pass1(Command c) {
		String message = "";
		for (String s : c.getParams()) {
			// evaluate the argument
			s = eval(s);
			// check if it's a string, because we need to extract it if it is.
			if (Equation.isString(s))
				s = DString.extractString(s);
			// append to message
			message += s;
		}
		// generate warning
		/*
		 * We're printing out a raw, untranslated string so we have to use
		 * DASM#warnMsg(String) instead of a simple #warn(String,Object...)
		 */
		getCompiler().warnMsg(message);
		return null;
	}
}
